import Request from '@/utils/http.js'
import operate from '@/utils/operate.js'
let http = new Request().http

export function get(url, data) {
	return http({
		url: url, //请求头
		method: "GET", //请求方式
		data: data, //请求数据
	})
}
export function post(url, data) {
	return http({
		url: url, //请求头
		method: "POST", //请求方式
		data: data, //请求数据
	})
}


export function upload(path, fileName, data) {
	// 返回promise
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: operate.api + '/file/upload', //你上传接口
			filePath: path, //上传的文件
			name: "file", //后台接收文件的标识
			formData: data,
			success: (res) => {
				res.data = JSON.parse(res.data)
				if (res.data.code === 200) {
					// 将结果抛出
					resolve(res.data.data)
				} else {
					uni.showToast({
						title: res.data.msg
					})
				}
			},
			fail: (err) => {
				reject(res)
			}
		});
	})

}
